<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="6" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 我的仪表盘 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <div style="display: flex;align-items: center;justify-content: center;">
                  <div id="all_chart" style="width:100%;height: 500px;"></div>
                </div>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="18" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 外购件列表 </span>
          </div>
          <div>
          </div>
          <el-select v-model="s_search.CMID7">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in l_firm" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <el-select v-model="s_search.CMID6">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in l_class" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select> 产品名称 <div class="el-select">
            <el-input v-model="s_search.product_name" />
          </div> 型号 <div class="el-select">
            <el-input v-model="s_search.product_model" />
          </div> 规格 <div class="el-select">
            <el-input v-model="s_search.product_norm" />
          </div>
          <el-button @click="getPage(1);" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
          <el-button @click="gotoPage('/psi/product/ProductBuyAdd?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加外购件</el-button>
          <el-table :data="pageList" v-loading="loading">
            <el-table-column label="#" align="center" type='index'>
            </el-table-column>
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_pi('&CMIDproduct_id='+scope.row.product_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/psi/product/ProductBuyDetUp?CMID='+scope.row.product_id+''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('D3BD08B63EF84DFF9AE7267B3899A4E1?&CMIDproduct_id='+scope.row.product_id+''+vueparams+'')">复制</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/psi/product/ProductDet?CMID='+scope.row.product_id+''+vueparams+'')">查看明细</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/psi/product/ProductPrice?CMID='+scope.row.product_id+''+vueparams+'')">价格体系</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="外购件条形码" prop="product_barcode">
            </el-table-column>
            <el-table-column label="外购件名称" prop="product_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/psi/product/AttributeProduct?CMID='+scope.row.product_id+''+vueparams+'')" type='primary'>{{scope.row.product_name}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="外购件类型" prop="product_classname">
            </el-table-column>
            <el-table-column label="外购件型号" prop="product_model" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column label="外购件规格" prop="product_norm" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column label="经济批量" prop="economic_batch">
            </el-table-column>
            <el-table-column label="供应厂家" prop="product_client_desc">
            </el-table-column>
            <el-table-column label="产品状态简述" prop="product_des">
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'CartogramPurchasedParts',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams("&CMID1=3&CMID5=3&CMODULEID=product_info"),
        s_search: {
          CMID7: null,
          CMID6: null,
          product_name: null,
          product_model: null,
          product_norm: null,
        },
        produce: [],
        all: [],
        l_firm: [],
        l_class: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/product/ProductSail/cartogramPurchasedParts?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          this.initChart();
        })
      },
      u_pc(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/product/ProductSail/u_pc?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_pi(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/product/ProductSail/d_pi?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      getPage(page) {
        this.loading = true;
        this.s_search.pageNo = page.page || page;
        this.s_search.pageSize = page.limit || 10;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/product/ProductSail/produce?' + this.vueparams,
          params: this.s_search
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      initChart() {
        var all_config = {
          legend: {
            data: getDataSet(this.all, "series")
          },
          tooltip: {},
          toolbox: {
            show: true,
            orient: 'vertical',
            left: 'right',
            top: 'center',
            feature: {
              mark: {
                show: true
              },
              dataView: {
                show: true,
                readOnly: false
              },
              magicType: {
                show: true,
                type: ['line', 'bar', 'stack', 'tiled']
              },
              restore: {
                show: true
              },
              saveAsImage: {
                show: true
              }
            }
          },
          series: [{
            type: "pie",
            data: getDataSeries(this.all),
            center: ["50%", "60%"], //圆心坐标
            radius: "55%" //远的半径
          }],
        };
        var myChart = this.initchart(document.getElementById('all_chart'));
        myChart.setOption(all_config);
      },
    },
  }
</script>
